﻿using System;
using System.Collections.Generic;
using System.Linq;
using Core.DataAccess;
using Core.Interfaces;

namespace SonCa.SocialNetwork.Web.HelperClass
{
    public class Translator
    {
        public static List<StatusUpdateCus> StatusUpdateToStatusUpdateCus(List<StatusUpdate> statusUpdate)
        {
            List<StatusUpdateCus> result = new List<StatusUpdateCus>();
            statusUpdate.ForEach(n => result.Add(new StatusUpdateCus {  CreateDate = n.CreateDate, Status = n.Status}));
            return result;
        }

        public static WebContextCus WebContextToWebContextCus(IWebContext _webContext, Folder.Type type)
        {
            return new WebContextCus { AccountID = _webContext.AccountID, FolderType = (int)type, RootURL = _webContext.RootUrl, AlbumID = _webContext.AlbumID };
        }

        public static List<HCFolder> FolderToHCFolder(List<Folder> folders)
        {
            List<HCFolder> result = new List<HCFolder>();
            if (folders.Count > 0)
            {
                folders.ForEach(n => result.Add(new HCFolder
                {
                    Name = string.Empty,
                    Username = string.Empty,
                    Location = string.Empty,
                    FolderID = n.FolderID.ToString(),
                    FullPathToCoverImage = string.Empty
                }));
            }
            return result;
        }

        public static List<HCFile> FileToHCFile(List<File> files)
        {
            List<HCFile> result = new List<HCFile>();
            if (files.Count > 0)
            {
                files.ForEach(n => result.Add(new HCFile 
                {
                    FileName = n.FileName,
                    Description = n.Description,
                    Year=n.CreateDate.Year.ToString(),
                    Month=n.CreateDate.Month.ToString(),
                    FileSystemName = n.FileSystemName.ToString(),
                    FileID=n.FileID.ToString(),
                    Extension = n.Extension
                }));
            }
            return result;
        }

        public static List<HCFile> UploadObjectToHCFile(List<FriendsProfile> files)
        {
            files.RemoveAll(n => n == null);
            List<HCFile> result = new List<HCFile>();
            if (files != null)
            {
                files.ForEach(n => result.Add(new HCFile
                {
                    FileName = n != null ? n.FileName : string.Empty,
                    Description = n != null ? n.Description : string.Empty,
                    Year = n != null ? n.CreateDatePhotos.Year.ToString() : "0",
                    Month = n.CreateDatePhotos.Month.ToString(),
                    FileSystemName = n != null ? n.FileSystemName.ToString() : string.Empty,
                    FileID = n != null ? n.FileID : string.Empty,
                    Extension = n != null ? n.Extension : string.Empty,
                }));
            }
            return result;
        }
    }
}